package com.asia5b.a5mall.middleware.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by zhangyuncai on 2019/12/20.
 */
public class MineTopView extends View {
    private static final String bottomBgColor = "#eeeeee";

    public MineTopView(Context context) {
        super(context);
    }

    public MineTopView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MineTopView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        float  bottomBgHeight = getHeight()/10f;
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(Color.parseColor(bottomBgColor));
        Path path = new Path();
        path.moveTo(0f, getHeight() - bottomBgHeight);
        path.lineTo(0, getHeight());
        path.lineTo(getWidth(), getHeight());
        path.lineTo(getWidth(), getHeight() - bottomBgHeight);
        path.quadTo(getWidth() / 2, getHeight() - bottomBgHeight / 3, 0, getHeight() - bottomBgHeight);
        canvas.drawPath(path, paint);
    }
}
